<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Arrays</title>
</head>
<body>
<div id="app">
    <span v-for="item in arrays" :key="index" v-text="item"></span><br>
    <input v-model="data" />
    <button @Click="push">追加</button>
    <button @Click="splice">替换指定位置</button>
</div>
<script src="../js/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            arrays: ['mack ','jack ','tom '],
            data: ''
        },
        methods: {
            push(){
                this.arrays.push(this.data+' ')
            },
            splice(){
                //参数1：起始位置 index
                //参数2：操作数据的个数
                //参数3：要替换的值
                //删除元素——没有参数3
                this.arrays.splice(0,1,this.data+' ')
            }
        }
    })
</script>
</body>
</html>